#pragma once
#include "JeayeSDK.h"

#define CC_MUTEX_TIMEDOUT    1

/** This is the timeout value which corresponds to never time out */
#define CC_MUTEX_MAXWAIT    (~(int32_t)0)

/** The CC mutex structure, defined in mutex.c */
typedef struct _cc_mutex cc_mutex_t;

/** Create a mutex, initialized unlocked */
JEAYESDK_API cc_mutex_t * cc_create_mutex(void);
/** Lock the mutex
*  @return TRUE, or FALSE on error
*/
JEAYESDK_API BOOL cc_mutex_lock(cc_mutex_t*);
/** Try Lock the mutex
*  @return 0, CC_MUTEX_TIMEDOUT, or -1 on error
*/
JEAYESDK_API int cc_mutex_try_lock(cc_mutex_t*);
/** Unlock the mutex
*  @return TRUE, or FALSE on error
*
*  It is an error to unlock a mutex that has not been locked by
*  the current thread, and doing so results in undefined behavior.
*/
JEAYESDK_API BOOL cc_mutex_unlock(cc_mutex_t*);
/** Destroy a mutex */
JEAYESDK_API void cc_destroy_mutex(cc_mutex_t**);